
package com.task.base;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class TaskReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();

        if (Util.ACTION_FREE_MEMORY.equals(action)) {
            Float free = Util.freeMemory(context);

            NumberFormat formater = DecimalFormat.getInstance();
            formater.setMaximumFractionDigits(2);
            formater.setMinimumFractionDigits(2);
            Toast.makeText(context,
                    formater.format(free) + context.getString(R.string.clear_memory_finish),
                    Toast.LENGTH_SHORT).show();

        }
    }

}
